"""
监理大事记
"""
import pytest
from Config.Base import Base
from playwright.sync_api import Page, expect, Playwright
import allure
from Config.config import *
from Config.URL import *
import os
from Config.AutoFlowEngine import autoflow


@pytest.mark.业务系统
@pytest.mark.综合管理
# @pytest.mark.parametrize('case', case_data)
def test_case(playwright : Playwright) -> None:
    # headless=False
    browser = playwright.chromium.launch(headless=False)
    context = browser.new_context()
    page = context.new_page()
    page.goto(url + url_login)
    page.get_by_placeholder("请输入用户名").fill("jianli1")
    page.get_by_placeholder("请输入密码").fill(password_admin)
    page.get_by_role("button", name="登 录").click()

    page.goto(url + url_jianlidashiji)
    page.get_by_placeholder("请选择标段").click()
    page.locator("ul").filter(has_text=re.compile(r"^应急供水工程施工监理标段$")).locator("span").click()
    page.get_by_role("button", name=" 新建").click()
    page.locator("form").filter(has_text="基础信息标题").get_by_placeholder("请输入标题").fill("AutoTest监理大事记")
    page.get_by_placeholder("请输入描述").fill("AutoTest描述")
    page.get_by_role("button", name="+ 新建").click()
    with page.expect_file_chooser() as fc_info:
        page.get_by_role("button", name="上传文件").click()
    file_chooser = fc_info.value
    file_chooser.set_files(test_datas_dir + "\用户导入模板.xlsx")
    allure.step("等待上传完成")
    page.wait_for_timeout(2000)
    page.get_by_role("button", name="确定").click()
    tool.starflow(page)

    autoflow(SetupTeardown, "AutoTest监理大事记")

    SetupTeardown.close()
